package com.bootdo.mall.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.bootdo.mall.dao.MallGoodDao;
import com.bootdo.mall.domain.MallGood;
import com.bootdo.mall.service.MallGoodService;



@Service
public class MallGoodServiceImpl implements MallGoodService {
	@Autowired
	private MallGoodDao mallGoodDao;
	
	@Override
	public MallGood get(Long id){
		return mallGoodDao.get(id);
	}

	@Override
	public MallGood getMin(Long id) {
		return mallGoodDao.getMin(id);
	}

	@Override
	public List<MallGood> list(Map<String, Object> map){
		return mallGoodDao.list(map);
	}

	@Override
	public List<MallGood> getGoodListByCategoryId(Map<String, Object> map) {
		return mallGoodDao.getGoodListByCategoryId(map);
	}

	@Override
	public Integer getGoodCountByCategoryId(Map<String, Object> map) {
		return mallGoodDao.getGoodCountByCategoryId(map);
	}

	@Override
	public List<MallGood> getGoodListByIndex(Map<String, Object> map) {
		return mallGoodDao.getGoodListByIndex(map);
	}

	@Override
	public Integer getGoodCountByIndex(Map<String, Object> map) {
		return mallGoodDao.getGoodCountByIndex(map);
	}

	@Override
	public Integer updateStockAdd(Integer stock, Long id) {
		return mallGoodDao.updateStockAdd(stock, id);
	}

	@Override
	public Integer updateStockDel(Integer stock, Long id) {
		return mallGoodDao.updateStockDel(stock, id);
	}

	@Override
	public int count(Map<String, Object> map){
		return mallGoodDao.count(map);
	}
	
	@Override
	public int save(MallGood mallGood){
	
		if(mallGood.getId() != null) {
			return mallGoodDao.update(mallGood);
		}else {
			return mallGoodDao.save(mallGood);
		}		
	
		
	}
	
	@Override
	public int update(MallGood mallGood){
		return mallGoodDao.update(mallGood);
	}
	
	@Override
	public int remove(Long id){
		return mallGoodDao.remove(id);
	}
	
	@Override
	public int batchRemove(Long[] ids){
		return mallGoodDao.batchRemove(ids);
	}
	
}
